#pragma once
#include "button.hpp"

namespace MFUI{
	class ProgressBar:public Button{
		protected:
		//调用check和released
		void _released(Window* w,SDL_FPoint p)override;
		void _losefocus(Window* w)override;
		void _pressed(Window* w,SDL_FPoint p)override;
		~ProgressBar()override;

		SDL_Color background,barcolor;
		float value;
		bool edit;

		public:
		//v有效范围0~1 edit为true时可被鼠标拖动修改
		ProgressBar(SDL_Color back,SDL_Color bar,float v,bool edit=true);

		float getvalue()const;
		//v有效范围0~1
		void setvalue(float v);
		void setbackground(SDL_Color c);
		void setbarcolor(SDL_Color c);
		void setedit(bool v);
		SDL_Color getbackground()const;
		SDL_Color getbarcolor()const;
		//实现自定义逻辑用
		virtual void changed();

		void draw(Renderer* r,bool updatecache)override;
		void mouseentered(Window* w)override;
		void mouseexited(Window* w)override;
		void mousemove(Window* w,SDL_FPoint p)override;
	};
}